#include "strindex.h"

int strrindex(char s[], char t[])
{
    //s is the string to be fitted, t is the pattern string
   
    int i, j, k, rindex = -1;
    //i is the length of string to be fitted (s),
    //j is the index of the array t,
    //k is the index of the array s

    for(i = 0; s[i] != '\0'; i++) {
        for(j = i, k = 0; t[k] != '\0' && s[j] == t[k]; j++, k++)
            ;
        if(k > 0 && t[k] == '\0')
            rindex = i;
    }

    return rindex;
}

